﻿<div class="select-none transition-colors border-r last:border-r-0 border-grey-900 px-4 py-2 cursor-pointer first:rounded-l last:rounded-r @(IsSelected ? "bg-accent2-900 text-grey-100" : "bg-dark-600 text-grey-400")"
     @onclick="OnClick"
     style="font-size: @(CultureInfo.CurrentCulture.Name == "ja-JP" ? 0.9 : 1)rem">
    @Text
</div>

@code
{
    [CascadingParameter]
    public ModTypeButtonGroup Parent { get; set; }

    [Parameter]
    public string Text { get; set; }

    [Parameter]
    public int Value { get; set; }

    public bool IsSelected { get; set; }

    protected override void OnInitialized()
    {
        if (Parent.Target == Value)
        {
            IsSelected = true;
        }

        Parent.AddChild(this);
    }

    private void OnClick()
    {
        if (!IsSelected)
        {
            Parent.SelectChild(this);
        }
    }
}